package com.jiepu.daily.corejava.advanceed.part7io.day0805;

import java.io.File;
import java.util.Scanner;

/**
 * @Description:
 * @author: xinjie
 * @date: 2020/8/5  10:45
 */
public class SearchDemo {
	static boolean match ;
	static String searchName;
	static  boolean ddd;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("input your search filename");
		searchName = scanner.nextLine();
		System.out.println("abs match ?");
		System.out.println("Y/N?");
		String s1 = scanner.nextLine();






		if ("Y".equals(s1.toUpperCase())) {
			System.out.println("ABS match... ");
			match = true;

		}
		// temp dir src
		File dir = new File("src");
		long t1 = System.currentTimeMillis();
		searchFile(dir);
		long t2 = System.currentTimeMillis();

		System.out.println("Time: " + (t2 - t1));

	} // main

	/**
	 * 默认在 src目录下 找
	 *
	 * @param file
	 */
	public static void searchFile(File file) {
		File[] files = null;
		// 判空
		if (file == null || (files = file.listFiles()) == null) {
			return;
		}
		// 递归 遍历 （src目录 下）  files
		for (File f : files) {
			if (f.getName().equals(searchName)) {
				System.out.println(f.getPath());
			}
			searchFile(f);
		} // for


	}


}
